package com.swpu.cbg.cnshop.utils;

import com.google.gson.Gson;
import com.swpu.cbg.cnshop.bean.ShoppingCart;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.security.spec.MGF1ParameterSpec;
import java.util.List;

/**
 * Created by chenboge on 16/2/11.
 */
public class JsonUtil {

    private static Gson mGson = new Gson();

    public static List<ShoppingCart> fromJson(String json, Type type) {
        List<ShoppingCart> carts = mGson.fromJson(json, type);
        return carts;
    }


    public static <T> T fromJson(String json,Class<T> clz){

        return  mGson.fromJson(json,clz);
    }


    public static <T> T FromJson(String json,Type type){

        return  mGson.fromJson(json, type);
    }


    public static String toJSON(Object object){

        return mGson.toJson(object);
    }


}
